#pragma once 

int read_input_momentabymomenta(char *dir,char *file, double **input)
{
	 char inputmom_file[1024];
	 //printf("Reading %s from %s\n",file,dir);

	// jk
         for (int imom=0; imom<Nmom; imom++)
         {
		sprintf(inputmom_file,"%s/p%03d/%s.jk",dir,imom,file);
	        FILE *fin=fopen(inputmom_file,"r");
         	if(fin == (FILE *)NULL) {
                	fprintf(stderr,"Unable to open file %s for reading\n",inputmom_file);
	                return EXIT_FAILURE;
        	 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) fscanf(fin,"%lf",&input[imom][iclust]);
		 fclose(fin);
        }

        return 0;
}
int read_input_onemomenta(char *dir,char *file, double *input, int imom)
{
         char inputmom_file[1024];
       //printf("Reading %s from %s\n",file,dir);

        // jk
                sprintf(inputmom_file,"%s/p%03d/%s.jk",dir,imom,file);
	//	 printf("%s\n",inputmom_file);
                FILE *fin=fopen(inputmom_file,"r");
                if(fin == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for reading\n",inputmom_file);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) fscanf(fin,"%lf",&input[iclust]);
		 //printf("Nclust %d \n",Nclust);
		 //for (int iclust=0; iclust<Nclust+1; iclust++) printf("%8.5f\n",input[iclust]);
                 fclose(fin);

        return 0;
}
int read_input_onemomenta_complex(char *dir,char *file, complex *input, int imom)
{
         char inputmom_file[1024];
//       printf("Reading %s from %s\n",file,dir);

        // jk
                sprintf(inputmom_file,"%s/p%03d/%s.jk",dir,imom,file);
                FILE *fin=fopen(inputmom_file,"r");
                if(fin == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for reading\n",inputmom_file);
                        return EXIT_FAILURE;
                 }
	double real, imag;
                 for (int iclust=0; iclust<Nclust+1; iclust++) {fscanf(fin,"%lf %lf",&real, &imag);		 input[iclust]=real+I*imag; }
                 fclose(fin);

        return 0;
}

